package StringHelper

import (
	"bytes"
	"encoding/json"
)

/**
map转json
 */
func MapToJson(data map[string]interface{}) (string, error) {
	if data == nil {
		data = map[string]interface{}{}
	}
	var buf bytes.Buffer
	err := json.NewEncoder(&buf).Encode(data)
	if err != nil {
		return "", err
	}
	return buf.String(), nil
}
